package 小红的ABC;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] ch = in.next().toCharArray();
        int n = ch.length;
        int res = -1;
        for (int i = 0; i < n - 1; i++) {
            if (ch[i] == ch[i + 1]) {
                res = 2;
                break;
            }
            if (i + 2 < n && ch[i] == ch[i + 2]) {
                res = 3;
            }
        }
        System.out.println(res);
    }
}
